package com.yloveg.base;

import java.util.Date; 
import javax.servlet.http.HttpServletRequest; 
import org.springframework.beans.factory.annotation.Autowired; 
import org.springframework.web.bind.WebDataBinder; 
import org.springframework.web.bind.annotation.InitBinder;

import com.yloveg.entity.ShopInfo;
import com.yloveg.entity.Suser;

public class BaseController { 
	public final static String SESSION_USER = "user";
	public final static String SESSION_SHOP = "shop"; 
	@Autowired 
	private HttpServletRequest request; 
	public void setSessionUser(Suser Suser) { 
		request.getSession(true).setAttribute(SESSION_USER, Suser); 
	} 
	public Suser getSessionUser() { 
		return (Suser) request.getSession().getAttribute(SESSION_USER); 
	} 
	public void setSessionShop(ShopInfo shop) { 
		request.getSession(true).setAttribute(SESSION_SHOP, shop); 
	} 
	public ShopInfo getSessionShop() { 
		return (ShopInfo) request.getSession().getAttribute(SESSION_SHOP); 
	} 
	public void setRequestAttr(String key, Object value) { 
		request.setAttribute(key, value); 
	} 
	/** 
	* 传入时间参数处理 
	* 
	* @param binder 
	*/ 
	@InitBinder 
	public void initBinder(WebDataBinder binder) { 
		binder.registerCustomEditor(Date.class, new DateEditor()); 
	} 
} 